package FirstStage.DuoTai;

public class DuoTaiCanShu {
    public static void main(String[] args) {
        // 多态参数： 方法定义的形参类型为父类类型，实参类型允许为子类类型
        Worker tom = new Worker("tom",2500);
        Manager milan = new Manager("milan",5000,20000);
        DuoTaiCanShu duoTaiCanShu =new DuoTaiCanShu();
        duoTaiCanShu.showEmpAnnual(tom);
        duoTaiCanShu.showEmpAnnual(milan);
        duoTaiCanShu.testWork(tom);
        duoTaiCanShu.testWork(milan);
    }

    public void showEmpAnnual(Empolyee e){
        System.out.println(e.getAnnual());
    }

    public void testWork(Empolyee e){
        if (e instanceof Worker){
            ((Worker) e).work();
        } else if (e instanceof Manager) {
            ((Manager) e).manage();
        }else {

        }
    }
}
